#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
using namespace std;
#include <unordered_map>
#include<queue>
int main() {
    int n;
    cin >> n;
    int m;
    cin >> m;
    unordered_map<int, int> hash;
    int _max = 0;
    for (int i = 0; i < n; i++)
    {
        int val;
        cin >> val;
        hash[val]++;
        _max = max(_max, hash[val]);
    }
    if (m == hash.size())
    {
        cout << _max << endl;
        return 0;
    }
    else if (m < hash.size())
    {
        cout << -1 << endl;
        return 0;
    }
    else {
        priority_queue<int> q;
        for (auto& e : hash)
        {
            q.push(e.second);
        }
        //cout<<q.size()<<endl;
        while (q.size() != m)
        {
            int top = q.top();
            q.pop();
            int tmp = top / 2;
            top -= tmp;
            q.push(tmp);
            q.push(top);
        }
        cout << q.top() << endl;
        return 0;
    }


}
#include <iostream>
using namespace std;

int main() {
    int y;
    cin >> y;
    int next = 0;
    int cur = 0;
    for (int i = 0; i * i <= y; i++)
    {
        cur = i * i;
        //cout<<prev<<" ";
        next = (i + 1) * (i + 1);
        //cout<<cur<<endl;
    }
    //cout<<cur<<" "<<next<<endl;
    if (cur == y)
    {
        cout << cur << endl;
        return 0;
    }
    if (y - cur <= next - y)
    {
        cout << cur << endl;
    }
    else {
        cout << next << endl;
    }
    return 0;

}